1. Field of the Invention
The present invention relates to a computer program product, system, and method for assigning device adaptors to use to copy source extents to target extents in a copy relationship.
2. Description of the Related Art
In a storage environment, volumes may be mirrored to other volumes to provide redundant copies of data. A point-in-time copy replicates data in a manner that appears instantaneous and allows a host to continue accessing the source volume while actual data transfers to the copy volume are deferred to a later time. The point-in-time copy appears instantaneous because complete is returned to the copy operation in response to generating the relationship data structures without copying the data. Point-in-time copy techniques, such as the IBM FlashCopy® (FlashCopy is a registered trademark of International Business Machines, Corp. or “IBM”), typically defer the transfer of a data back to the copy volume until a write operation is requested to that data block on the source volume. Data transfers may also proceed as a background copy process with minimal impact on system performance. Until the actual data transfer occurs, reads are directed to the data blocks on the source volume. The point-in-time copy relationships that are immediately established in response to the point-in-time copy command include a bitmap or other data structure indicating the location of blocks in the volume at either the source volume or the copy volume.
A storage controller that receives establish FlashCopy commands to establish multiple copy relations of source volumes to target volumes may not have sufficient available resources to perform all of the corresponding background copy tasks simultaneously for all the copy relations. Available resources are limited by the ranks, device adapters and available tasks. For instance, in certain systems, a maximum of four background copy tasks per device adapter can be active at once. Thus, if there are four device adaptors, then there may be a maximum of 16 active background copy tasks. When a background copy operation for a relation is registered to copy a source volume to a target volume, the copy relation is put into a Background Copy Control Throttling (BCCT) rank queue and into a BCCT priority queue to wait for an opportunity to start copying. The BCCT scheduler is then dispatched. The purpose of the rank queues is to balance the work between the device adapters and between the ranks. The purpose of the priority queue is to choose background copy tasks for relations according to the importance of running the task. The BCCT scheduler will locate a target relation to activate its background copy task based on the priority of the relation and the device adaptor and rank constraints. The BCCT scheduler searches for a candidate by first querying the BCCT priority queue. Priorities in the priority queue are set based upon the time the copy relation was established. The BCCT scheduler ensures that the N (such as 4) highest priority relations in the cluster are currently copying. If they are already running, then the BCCT scheduler will go through the first C (say 100) elements in the priority queue to find a relation that fits the rank and device adaptor. If a relation is found, then the BCCT scheduler activates the copy relation. Otherwise, the BCCT scheduler searches through device adapter and rank structures to find a suitable candidate on which to activate the agent.
The BCCT scheduler determines which relations fit the rank and device adaptor constraints by using the following preference algorithm:                1. Choose a device adaptor with less than the maximum number of active background copy tasks that are using this device adaptor, e.g., 4.        2. Choose a device adaptor with the least number of active background copy tasks that are using this device adaptor.        3. Choose a rank under that device adaptor with the least number of active background copy tasks that are running in this cluster.        4. Choose a device adaptor with the highest number of waiting agents.        
The BCCT scheduler maintains data structures to assign relations and their ranks to source and target device adaptors. A BCCT rank queue has entries linked into two separate queues, the corresponding rank queue and the cluster's priority queue. The target relation entry contains pointers to the previous and the next relation entry in each one of the queues. Two pointers are needed for each list to support insertion and removal of elements from the middle of the queue. The priority queue contains the relations that are waiting for the background copy task to start in the order of importance. The order of the elements in the queue will be dynamically changed according to the current importance of each relation. For the first phase of implementation, the order of the elements in the priority queue will be according to the establish time. The relation will be inserted to the priority queue only after the asynchronous destage and discard scans complete in order to improve the performance of the background copy task. In the second phase, preference is added to the priority queue and the placement of the elements in the queue are changed dynamically. The purpose of the device adaptor (DA) and rank structures is to allow fast searching for a relation that fits the rank and DA constraints.
FIG. 1 illustrates an embodiment of the device adaptor 2 and rank 4 data structures as known in the prior art. An array 2 of target device adaptor entries includes one entry 6a, 6b, 6c . . . 6n for each possible target device adaptor and a list of ranks 8a, 8b, 8c . . . 8n assigned to each target device adaptor 6a, 6b, 6c . . . 6n, respectively. The lists 8a, 8b, 8c . . . 8n each include ranks that have target relations which are waiting for the background copy task to start. The list is dynamic, i.e. ranks are added and deleted when adding and removing the first and the last target relation for the rank. Further, for each target device adaptor there are counters of active and waiting agents. The counters are used to optimize the search algorithm and to choose an agent according to the DA's throughput limitations.
For the source ranks, there is an array of n rank entries 10a, 10b . . . 10n, one entry 10a, 10b . . . 10n for each of the n ranks in the system. For each rank entry 10a, 10b . . . 10n there are four anchors 12a, 12b . . . 12n (only one set of the anchors for rank 10a is shown in FIG. 1), one for each source device adaptor, where each anchor 12a, 12b . . . 12n links to a relation list 14a, 14b . . . 14n of relations that are waiting for background copy tasks to start. There is one anchor 12a, 12b . . . 12n for each device adaptor in the cluster. The device adaptor represented by the anchor 12a, 12b . . . 12n is used to copy the source extent from the source rank to the target rank. For each source device adaptor represented by the anchors 12a, 12b . . . 12n, there is a counter of active agents on the rank. The counter is used to optimize the search algorithm and to choose an agent according to the rank's throughput limitations. Further, there are pointers to the previous and the next ranks 10a, 10b . . . 10n in the rank list 4. The BCCT scheduler locates the relation that fits the rank and device adaptor by querying only the top of the ranks queues.
To copy a source extent to a target extent for a relation accessed from the priority queue, a plurality of copy agents may be assigned to copy the extent. Each of the assigned background copy agents processes a different section of the volume. These agents are running at the same time. The background copy agents start copying from the end of their region to the beginning of the region. Because a target of the relation may have extents from many different ranks, current background copy agents copy extents in the order of rank number (lowest rank number to highest rank number). If there are background copy tasks for many relations, then all agents will first queue ranks in order, rank 0, rank 1, rank 2 etc.
There is a need in the art for improved techniques for allocating agents to copy source extents from source ranks to target extents in target ranks as part of a copy operation.